//
//  ReportCell.m
//  mendianjieke
//
//  Created by 响当当 on 10/29/19.
//  Copyright © 2019 dongzheng. All rights reserved.
//

#import "ReportCell.h"

@interface ReportCell()
@property (nonatomic, strong)UIImageView *headImageView;
@property (nonatomic, strong)UILabel *sexLabel;
@property (nonatomic, strong)UILabel *ageLabel;
@property (nonatomic, strong)UIImageView *inImageView;
@property (nonatomic, strong)UILabel *timeLabel;
@property (nonatomic, strong)UIImageView *outImageView;
@property (nonatomic, strong)UILabel *dealLabel;
@end

@implementation ReportCell

- (UIImageView *)headImageView
{
    if (!_headImageView)
    {
        _headImageView = [[UIImageView alloc]initWithFrame:CGRectMake(15*kUIScaleBasePlus,10*kUIScaleBasePlus,30*kUIScaleBasePlus,30*kUIScaleBasePlus)];
        _headImageView.layer.masksToBounds = YES;
        _headImageView.layer.cornerRadius = _headImageView.frame.size.height/2;
    }
    return _headImageView;
}

- (UILabel *)sexLabel
{
    if (!_sexLabel)
    {
        _sexLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.headImageView.frame)+10*kUIScaleBasePlus,16*kUIScaleBasePlus,13*kUIScaleBasePlus,18.5*kUIScaleBasePlus)
                                     textAligment:NSTextAlignmentCenter
                                         textClor:LCHexColor(0x282828)
                                         textFont:13*kUIScaleBasePlus];
        
    }
    return _sexLabel;
}

- (UILabel *)ageLabel
{
    if (!_ageLabel)
    {
        _ageLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.sexLabel.frame)+30.5*kUIScaleBasePlus,16*kUIScaleBasePlus,29*kUIScaleBasePlus,18.5*kUIScaleBasePlus)
                                     textAligment:NSTextAlignmentCenter
                                         textClor:LCHexColor(0x282828)
                                         textFont:12*kUIScaleBasePlus];
        
    }
    return _ageLabel;
}

- (UIImageView *)inImageView
{
    if (!_inImageView)
    {
        _inImageView = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.ageLabel.frame)+32*kUIScaleBasePlus,15.5*kUIScaleBasePlus,17*kUIScaleBasePlus,17*kUIScaleBasePlus)];
    }
    return _inImageView;
}

- (UILabel *)timeLabel
{
    if (!_timeLabel)
    {
        _timeLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.inImageView.frame)+2*kUIScaleBasePlus,16*kUIScaleBasePlus,90*kUIScaleBasePlus,18.5*kUIScaleBasePlus)
                                     textAligment:NSTextAlignmentCenter
                                         textClor:LCHexColor(0x282828)
                                         textFont:13*kUIScaleBasePlus];
        
    }
    return _timeLabel;
}

- (UIImageView *)outImageView
{
    if (!_outImageView)
    {
        _outImageView = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.timeLabel.frame)+5*kUIScaleBasePlus,15.5*kUIScaleBasePlus,17*kUIScaleBasePlus,17*kUIScaleBasePlus)];
    }
    return _outImageView;
}


- (UILabel *)dealLabel
{
    if (!_dealLabel)
    {
        _dealLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.outImageView.frame)+25*kUIScaleBasePlus,16*kUIScaleBasePlus,39*kUIScaleBasePlus,18.5*kUIScaleBasePlus)
                                     textAligment:NSTextAlignmentCenter
                                         textClor:LCHexColor(0x282828)
                                         textFont:12*kUIScaleBasePlus];
        
    }
    return _dealLabel;
}



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self.contentView addSubview:self.headImageView];
        [self.contentView addSubview:self.sexLabel];
        [self.contentView addSubview:self.ageLabel];
        [self.contentView addSubview:self.inImageView];
        [self.contentView addSubview:self.timeLabel];
        [self.contentView addSubview:self.outImageView];
        [self.contentView addSubview:self.dealLabel];
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0,49*kUIScaleBasePlus,SCREEN_WIDTH,0.5*kUIScaleBasePlus)];
        lineView.backgroundColor = JSALineColor;
        [self.contentView addSubview:lineView];
    }
    return self;
}

- (void)getInfo:(ReportGuestModel *)model
{
    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:model.photo] placeholderImage:[UIImage imageNamed:@"wode2"]];
    self.sexLabel.text = model.gender.integerValue == 1 ? @"男" : @"女";
    self.ageLabel.text = [NSString stringWithFormat:@"%@岁",model.age.stringValue];
    
    switch (model.inF.integerValue)
    {
        case 0:
        {
            self.inImageView.image = [UIImage imageNamed:@"jingya"];
        }
            break;
        case 3:
        {
            self.inImageView.image = [UIImage imageNamed:@"kaixin"];
            
        }
            break;
        case 4:
        {
            self.inImageView.image = [UIImage imageNamed:@"beishang"];
            
        }
            break;
        case 5:
        {
            self.inImageView.image = [UIImage imageNamed:@"shengqi"];
            
        }
            break;
        case 6:
        {
            self.inImageView.image = [UIImage imageNamed:@"pingjing"];
            
        }
            break;
        default:
            break;
    }
    
    self.timeLabel.text = [NSString stringWithFormat:@"%@-%@",[Utilties getHMS:model.inTime.stringValue],[Utilties getHMS:model.outTime.stringValue]];
    
    switch (model.outF.integerValue)
          {
                  
              case 0:
              {
                  self.outImageView.image = [UIImage imageNamed:@"jingya"];
              }
                  break;
              case 3:
              {
                  self.outImageView.image = [UIImage imageNamed:@"kaixin"];
                  
              }
                  break;
              case 4:
              {
                  self.outImageView.image = [UIImage imageNamed:@"beishang"];
                  
              }
                  break;
              case 5:
              {
                  self.outImageView.image = [UIImage imageNamed:@"shengqi"];
                  
              }
                  break;
              case 6:
              {
                  self.outImageView.image = [UIImage imageNamed:@"pingjing"];
                  
              }
                  break;
              default:
                  break;
          }
    
    self.dealLabel.text = model.state.integerValue == 1 ? @"已成交" : @"未成交";
    
    self.dealLabel.textColor = model.state.integerValue == 1 ? LCHexColor(0x929292) : LCHexColor(0x02B98E);
}
@end
